package cn.im;


import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

import java.util.concurrent.TimeUnit;

@SpringBootApplication
public class ProviderApplication {
    public static void main(String[] args) throws InterruptedException {
        ConfigurableApplicationContext context = SpringApplication.run(ProviderApplication.class, args);

        while (true) {
            //当动态配置刷新时，会更新到 Enviroment中，因此这里每隔一秒中从Enviroment中获取配置
            String username = context.getEnvironment().getProperty("spring.haha");
            System.out.println("spring.haha:" + username);

            System.out.println("spring.datasource.username: "+ context.getEnvironment().getProperty("spring.datasource.username"));
            TimeUnit.SECONDS.sleep(1);
        }
    }
}
